package com.demo.datastructure.reorder.bubbleSort;

/**
 * @description: 冒泡排序实现
 * @author: ljr
 * @time: 2021/5/2 16:19
 */
public class MyBubbleSort {

    public void bubbleSort(int[] args, int n){
        for(int i = 0; i< n; i++){
            boolean flag = true;
            for(int a=0; a < n-1-i; n++){
                if(args[a] > args[a+1]){
                    int val = args[a+1];
                    args[a+1] = args[a];
                    args[a] = val;
                    flag =false;
                }
            }

            if(flag){
                break;
            }
        }
    }

}
